<?php

namespace app\web\controller;

use app\web\service\DriverService;
use app\web\service\UserService;
use app\web\service\VerifierService;

class UserController extends CommonController
{
    public function initialize()
    {
        parent::initialize();
    }

    //获取登录用户基本信息
    public function getUserInfo(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(UserService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getInfo(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //司机首页信息
    public function getDriverIndex(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->driverIndex(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //司机个人信息
    public function getDriverInfo(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->driverInfo(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //司机更新个人信息
    public function toUpdateDriverInfo(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->updateDriverInfo(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //更新司机状态
    public function toUpdateDriverStatus(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->updateDriverStatus(); // 处理业务
        return $this->return_result($this->returnData);
    }

    // 司机钱包列表
    public function getDriverWallet(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->driverWallet(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //司机去提现了
    public function toDriverWithdraw(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toDriverWithdraw(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //司机订单详情
    public function getDriverOrderDetail(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getOrderDetail(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //待接收的司机订单
    public function getDriverNoReceivedOrder(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->driverNoReceivedOrder(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //拒接收的订单
    public function toDriverRefuseOrder(){ // 4
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->driverRefuseOrder(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //接收订单
    public function toDriverAcceptOrder(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->driverAcceptOrder(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //已接收的司机订单
    public function getDriverReceivedOrder(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->driverReceivedOrder(); // 处理业务
        return $this->return_result($this->returnData);
    }

    // 完成司机订单
    public function toDriverFinishOrder(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->driverFinishOrder(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //已完成的司机订单
    public function getDriverCompleteOrder(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(DriverService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->driverCompleteOrder(); // 处理业务
        return $this->return_result($this->returnData);
    }

    // 核销员首页信息
    public function getVerifierIndex(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(VerifierService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->verifierIndex(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //司机个人信息
    public function getVerifierInfo(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(VerifierService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->VerifierInfo(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //司机更新个人信息
    public function toUpdateVerifierInfo(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(VerifierService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->updateVerifierInfo(); // 处理业务
        return $this->return_result($this->returnData);
    }

    //更新司机状态
    public function toUpdateVerifierStatus(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(VerifierService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->updateVerifierStatus(); // 处理业务
        return $this->return_result($this->returnData);
    }

    // 核销员核销线路列表
    public function verifierClassesList(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(VerifierService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->verifierClassesList(); // 处理业务
        return $this->return_result($this->returnData);
    }

    // 核销员核销线路列表
    public function getClassesInfo(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(VerifierService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getClassesInfo(); // 处理业务
        return $this->return_result($this->returnData);
    }
}